/*
 * 版权所有 (C) 2015 知启蒙(ZHIQIM) 保留所有权利。[遇见知启蒙，邂逅框架梦]
 * 
 * https://zhiqim.org/project/zhiqim_framework/zhiqim_httpd.htm
 *
 * Zhiqim Httpd is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */
package org.zhiqim.httpd.websocket;

import org.zhiqim.httpd.HttpSession;
import org.zhiqim.httpd.HttpSessionManager;
import org.zhiqim.httpd.HttpSessionUser;
import org.zhiqim.httpd.HttpdConstants;
import org.zhiqim.kernel.model.maps.HashMapSS;
import org.zhiqim.kernel.logging.Log;
import org.zhiqim.kernel.logging.LogFactory;


/**
 * Websocket连接
 *
 * @version v1.0.0 @author zouzhigang 2018-5-29 新建与整理
 */
public interface HttpWebSocket extends HttpdConstants
{
    public Log log = LogFactory.getLog(HttpWebSocket.class);
    
    /***********************************************************************************/
    //打开&关闭
    /***********************************************************************************/
    
    /** 启动 */
    public void open();
    
    /** 关闭连接通知并删除 */
    public void close(int code);
    
    /** 异常连接通知并删除 */
    public void exception(Throwable e);
    
    /***********************************************************************************/
    //发送数据
    /***********************************************************************************/
    
    /** 发送PING消息 */
    public boolean sendPing();
    
    /** 发送PONG消息 */
    public boolean sendPong();
    
    /** 发送关闭消息 */
    public boolean sendClose(int code);
    
    /** 发送文本消息 */
    public boolean sendText(String text);
    
    /** 发送二进制数据 */
    public boolean sendBinary(byte[] binary);
    
    /***********************************************************************************/
    //获取属性
    /***********************************************************************************/
    
    /** 获取协议 */
    public String getProtocol();
    
    /** 获取会话管理器 */
    public HttpSessionManager getSessionManager();
    
    /** 获取会话编号 */
    public String getSessionId();
    
    /** 获取会话信息 */
    public HttpSession getSession();
    
    /** 获取会话用户信息 */
    public HttpSessionUser getSessionUser();
    
    /** 获取Websocket管理器 */
    public HttpWebSocketManager getWebSocketManager();
    
    /** 获取WebSocket服务 */
    public HttpWebSocketService getWebSocketService();
    
    /** 获取WebSocket连接上来时的头部表 */
    public HashMapSS getHeaderMap();
    
    /** 获取WebSocket连接上来时的头部 */
    public String getHeader(String name);
    
    /** 获取WebSocket连接上来时的参数表 */
    public HashMapSS getParameterMap();
    
    /** 获取WebSocket连接上来时的参数 */
    public String getParameter(String name);
}
